package com.ruoyi.project.xkx.student.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.project.xkx.student.domain.IdAndListId;
import com.ruoyi.project.xkx.student.domain.XkxStudent;
import com.ruoyi.project.xkx.student.mapper.XkxStudentMapper;
import com.ruoyi.project.xkx.student.service.XkxStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class XkxStudentServiceImpl extends ServiceImpl<XkxStudentMapper, XkxStudent> implements XkxStudentService {




    @Autowired
    private XkxStudentMapper xkxStudentMapper;

    /**
     * 查询正式学员
     * */
    @Override
    public Page<XkxStudent> getFormalStu(Page<XkxStudent> stu,Integer schoolId, Integer userId, String studentName, String studentPhone) {
        return xkxStudentMapper.getFormalStu(stu,schoolId,userId,studentName,studentPhone);
    }
    /**
     * 查询意向学员
     * */
    @Override
    public Page<XkxStudent> getIntentionStu(Page<XkxStudent> stu, Integer schoolId, Integer userId, String studentName, String studentPhone) {
        return xkxStudentMapper.getIntentionStu(stu,schoolId,userId,studentName,studentPhone);
    }

    /**
     * 到期提醒
     * */
    @Override
    public Page<XkxStudent> remind(Page<XkxStudent> stu,Integer schoolId, Integer timeNum, Integer clsHourNum) {
        return xkxStudentMapper.remind(stu,schoolId,timeNum,clsHourNum);
    }

    @Override
    public Page<XkxStudent> getBindAdviserError(Page<XkxStudent> stu, Integer schoolId, String studentName, String studentPhone) {
        return xkxStudentMapper.getBindAdviserError(stu,schoolId,studentName,studentPhone);
    }


    /**
     * 更改课程顾问绑定
     * */
    @Override
    @Transactional
    public Boolean editAdviser(IdAndListId idList){

        for(Integer stuId:idList.getIdList() ){

            xkxStudentMapper.editAdviser(idList.getId(),stuId);

        }
        if( idList.getId() == null){
            return false;
        }
        return true;
    }

    @Override
    public XkxStudent getStudentByStudentNumber(String studentNumber) {
        return xkxStudentMapper.getStudentByStudentNumber(studentNumber);
    }
    /**
     * 前台小程序根据课程顾问id查询查询正式学员
     * */
    @Override
    public List<XkxStudent> getFormalStuByUserId(Integer userId, String searchData) {
        return xkxStudentMapper.getFormalStuByUserId(userId,searchData);
    }

    /**
     * 前台小程序根据课程顾问id查询查询意向学员
     * */
    @Override
    public List<XkxStudent> getIntentionStuByUserId(Integer userId, String searchData) {
        return xkxStudentMapper.getIntentionStuByUserId(userId,searchData);
    }

    /**
     * 前台小程序根据课程顾问id查询查询课程快到期学员
     * */
    @Override
    public List<XkxStudent> getRemindStuByUserId(Integer userId) {
        return xkxStudentMapper.getRemindStuByUserId(userId);
    }

    /**
     * 前台小程序根据学员id查询正式学员信息
     * */
    @Override
    public XkxStudent getOneStudentByStudentId(Integer studentId) {
        return xkxStudentMapper.getOneStudentByStudentId(studentId);
    }

    /**
     * 前台小程序根据学员id查询意向学员信息
     * */
    @Override
    public XkxStudent getOneIntentionStuByStudentId(Integer studentId) {
        return xkxStudentMapper.getOneIntentionStuByStudentId(studentId);
    }
}
